// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueResource from 'vue-resource'
import picker from 'vue-3d-picker'

Vue.use(VueResource)
Vue.config.productionTip = false
Vue.component(picker.name, picker)
Vue.http.options.emulateJSON = true

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})

//api请求地址
// Vue.prototype._API_ = "http://answer.rcwlkj.top/Api/Index/"
// Vue.prototype._API_ = "http://answer.com/Api/Index/"
Vue.prototype._API_ = "http://assessment.mumtalks.cn/Api/Index/";

//获取get参数
Vue.prototype.GetQueryString = function (name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}

//判断是否邮箱
Vue.prototype.isEmail = function ( str ) {
    var reg =/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
    return reg.test(str)
}

//获取两个时间的月份差
Vue.prototype.getMonthNumber = function (date1,date2){
    //默认格式为"20030303",根据自己需要改格式和方法
    var year1 =  date1.substr(0,4);
    var year2 =  date2.substr(0,4);
    var month1 = date1.substr(4,2);
    var month2 = date2.substr(4,2);

    var len=(year2-year1)*12+(month2-month1);

    return len;

}

//获取当前日期
Vue.prototype.getNowFormatDate = function () {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
    return currentdate;
}